#pragma once
#include "core/syscall.h"
#include "os_cfg.h"
#include "comm/types.h"
#include "sys/stat.h"
#define  SYS_sleep      0
#define  SYS_getpid     1
#define  SYS_printmsg   2
#define  SYS_fork       3
#define  SYS_execve     4
#define  SYS_yield      5
#define  SYS_exit       6
#define  SYS_wait       7

#define  SYS_open       50
#define  SYS_read       51
#define  SYS_write      52
#define  SYS_close      53
#define  SYS_lseek      54

#define  SYS_fstat      55  
#define  SYS_sbrk       56  
#define  SYS_isatty     57  
#define  SYS_dup        58 

#define SYS_opendir		60
#define SYS_readdir		61
#define SYS_closedir	62
#define SYS_ioctl    	63

#define SYS_unlink      64

//系统调用参数
typedef struct _syscall_args_t
{
    int id;
    int arg0;
    int arg1;
    int arg2;
    int arg3;
}syscall_args_t;


void msleep(int ms);
int getpid(void);
int print_msg(const char* s,int arg);
int fork(void);
int execve(const char* name,char* argv, char* const* env);
int yield();



int open(const char *name, int flags, ...);
int read(int file, char *ptr, int len);
int write(int file, char *ptr, int len);
int close(int file);
int lseek(int file, int ptr, int dir);
int ioctl(int file, int cmd, int arg0,int arg1);
int unlink(const char* pathname);

int isatty(int file);
int fstat(int file,struct stat* st);
void* sbrk(ptrdiff_t incr);

int dup(int fd);

void _exit(int status);
int  wait(int* status);



struct dirent 
{
   int index;         // 在目录中的偏移
   int type;            // 文件或目录的类型
   char name [255];       // 目录或目录的名称
   int size;            // 文件大小
};

typedef struct _DIR 
{
    int index;               // 当前遍历的索引
    struct dirent dirent;
}DIR;

DIR * opendir(const char * name);
struct dirent* readdir(DIR* dir);
int closedir(DIR *dir);